package company.chubao;

import java.util.Scanner;

public class Chu5 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int maxSpeed = sc.nextInt();
        int n = sc.nextInt();
        double[] distance = new double[n];
        int[] time = new int[n];
        for (int i = 0; i < n; i++) {
            distance[i] = sc.nextInt() * 3.6;
            time[i] = sc.nextInt();
        }
        for (int i = maxSpeed; i >= 0; i--) {
            if (canMove(i, n, distance, time)) {
                System.out.println(i);
                return;
            }
        }
    }

    private static boolean canMove(int maxSpeed, int n, double[] distance, int[] time) {
        for (int i = 0; i < n; i++) {
            double d = distance[i];
            int t = (int) (d / maxSpeed) + (d % maxSpeed == 0 ? 0 : 1);
            int v = t / time[i];
            if (v % 2 == 0)
                return true;
        }
        return false;
    }
}
